package com.haima.sage.bigdata.api.frame.condition.expression.impl;

import java.util.Date;

import com.haima.sage.bigdata.api.frame.condition.expression.BaseLogicService;

public class LeLogicService extends BaseLogicService {
    public LeLogicService(Object param) {
        super(param);
    }

    @Override
    protected boolean logicNotEmpty(String object) throws Exception {
        return object.compareTo(strParam) <= 0;
    }

    @Override
    protected boolean logicNotEmpty(Date object) throws Exception {
        return object.getTime() <= dateParam;
    }

    @Override
    protected boolean logicNotEmpty(Byte object) throws Exception {
        if (byteParam != null) {
            return object <= byteParam;
        }
        return object.toString().compareTo(strParam) <= 0;
    }

    @Override
    protected boolean logicNotEmpty(Short object) throws Exception {
        if (shortParam != null) {
            return object <= shortParam;
        }
        return object.toString().compareTo(strParam) <= 0;
    }

    @Override
    protected boolean logicNotEmpty(Integer object) throws Exception {
        if (intParam != null) {
            return object <= intParam;
        }
        return object.toString().compareTo(strParam) <= 0;
    }

    @Override
    protected boolean logicNotEmpty(Long object) throws Exception {
        if (longParam != null) {
            return object <= longParam;
        }
        return object.toString().compareTo(strParam) <= 0;
    }

    @Override
    protected boolean logicNotEmpty(Float object) throws Exception {
        if (floatParam != null) {
            return object <= floatParam;
        }
        return object.toString().compareTo(strParam) <= 0;
    }

    @Override
    protected boolean logicNotEmpty(Double object) throws Exception {
        if (doubleParam != null) {
            return object <= doubleParam;
        }
        return object.toString().compareTo(strParam) <= 0;
    }

    @Override
    protected boolean logicNotEmpty(Boolean object) throws Exception {
        if (boolParam != null) {
            return object.compareTo(boolParam) <= 0;
        }
        return object.toString().compareTo(strParam) <= 0;
    }

    @Override
    protected boolean logicNotEmpty(Character object) throws Exception {
        return object.compareTo(charParam) <= 0;
    }
}
